<%@ Page Language="C#" MasterPageFile="~/Masterpages/Default.master" AutoEventWireup="true"
    Inherits="protected_ManageSites" Title="Manage Sites" Codebehind="ManageSites.aspx.cs" %>

<%@ Register Assembly="System.BusinessObjects.Framework" Namespace="System.BusinessObjects.Controls"
    TagPrefix="cc1" %>
<%@ Register Assembly="System.Web.Extensions, Version=1.0.61025.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35"
    Namespace="System.Web.UI" TagPrefix="asp" %>
<%@ Register Src="../Usercontrols/Loading.ascx" TagName="Loading" TagPrefix="uc3" %>
<%@ Register TagPrefix="uc1" Namespace="Blazing.UI.Cms.Admin.Classes" Assembly="Blazing.UI.Cms.Admin" %>

<asp:Content ID="Content1" ContentPlaceHolderID="ContentPlaceHolder1" runat="Server">
    <h1>Manage Sites</h1>
    <ajax:UpdatePanel ID="UpdatePanel1" runat="server">
    <ContentTemplate>        
    <ajax:TabContainer ID="TabContainer1" runat="server">
    <ajax:TabPanel ID="TabItem1" runat="server" HeaderText="Sites">
    <ContentTemplate>  
        <div class="grid">  
            <asp:GridView ID="GridView1" runat="server" AllowPaging="True" AutoGenerateColumns="False"
                CaptionAlign="Left" CssClass="gridview" CellPadding="4" DataKeyNames="RowStamp,ID,RowState" DataSourceID="odsSites"
                ForeColor="#333333" GridLines="None" EmptyDataText="There are no sites in this database.">
                <Columns>
                    <asp:BoundField DataField="ID" HeaderText="ID" ReadOnly="True" SortExpression="ID" />
                    <asp:BoundField DataField="Name" HeaderText="Name" SortExpression="Name" />
                    <asp:BoundField DataField="Url" HeaderText="Url" SortExpression="Url" />
                    <asp:CommandField ShowDeleteButton="True" ShowEditButton="True">
                        <ControlStyle CssClass="command" />
                    </asp:CommandField>
                </Columns>
                <FooterStyle BackColor="#5D7B9D" Font-Bold="True" ForeColor="White" />
                <AlternatingRowStyle CssClass="row alt" />
                <EditRowStyle CssClass="edit-info" />               
                <HeaderStyle CssClass="gridheader" />
                <PagerStyle BackColor="#284775" ForeColor="White" HorizontalAlign="Center" />
                <RowStyle CssClass="row" />
            </asp:GridView>
        </div>  
        <br />
        <asp:LinkButton ID="LinkButtonInsert" runat="server">Insert</asp:LinkButton><br />
        <asp:Panel ID="PanelAddSite" runat="server">
            <uc1:RoundedPanel ID="rp1" runat="server" width="400px">
                <div class="grid">
                    <div class="gridview">
                         <div class="gridheader"> 
                            Add Site
                         </div>
                        <asp:DetailsView ID="DetailsView1" runat="server" AutoGenerateRows="False" 
                             BorderWidth="0px" Width="100%"
                            DataKeyNames="ID" DataSourceID="odsSites" DefaultMode="Insert" 
                             OnItemCommand="DetailsView1_ItemCommand">
                            <Fields>
                                <asp:BoundField DataField="ID" HeaderText="ID" InsertVisible="False" ReadOnly="True"
                                    SortExpression="ID" />
                                <asp:BoundField DataField="Name" HeaderText="Name" SortExpression="Name" />
                                <asp:BoundField DataField="Url" HeaderText="Url" SortExpression="Url" />
                                <asp:CommandField ShowInsertButton="True" />
                            </Fields>
                            <RowStyle CssClass="row" />
                            <EditRowStyle CssClass="edit-info" />               
                            <PagerStyle BackColor="White" ForeColor="White" HorizontalAlign="Center" />
                            <HeaderStyle CssClass="gridheader" />
                            <AlternatingRowStyle CssClass="row alt" />
                        </asp:DetailsView>
                    </div>
                </div>           
            </uc1:RoundedPanel>
        </asp:Panel>
           
    <ajax:ModalPopupExtender ID="ModalPopupExtender1" runat="server" TargetControlID="LinkButtonInsert"
        PopupControlID="PanelAddSite" PopupDragHandleControlID="PanelAddSiteTitle" 
            SkinID="Popup1" DynamicServicePath="" Enabled="True">
    </ajax:ModalPopupExtender> 
    </ContentTemplate>    
    </ajax:TabPanel>
    
    <ajax:TabPanel ID="TabPanel2" runat="server" HeaderText="Site Aliases">
    <ContentTemplate>
        <div class="grid">
            <asp:GridView ID="GridViewSiteAliases" runat="server" AllowPaging="True" AutoGenerateColumns="False"
                CaptionAlign="Left" CellPadding="4" CssClass="gridview" DataSourceID="odsSiteAliases" ForeColor="#333333"
                GridLines="None" EmptyDataText="There are no site aliases in this database." DataKeyNames="ParentSite,Name,Url">
                <Columns>
                    <asp:TemplateField HeaderText="ParentSite" SortExpression="ParentSite">
                        <ItemTemplate>
                            <asp:Label ID="Label1" runat="server" Text='<%# Eval("ParentSite.Name") %>'></asp:Label>
                        </ItemTemplate>
                    </asp:TemplateField>
                    <asp:BoundField DataField="Name" HeaderText="Name" SortExpression="Name" />
                    <asp:BoundField DataField="Url" HeaderText="Url" SortExpression="Url" />
                    <asp:CommandField ShowDeleteButton="True" />
                </Columns>
                <RowStyle CssClass="row" />
                <EditRowStyle CssClass="edit-info" />               
                <PagerStyle BackColor="#284775" ForeColor="White" HorizontalAlign="Center" />
                <HeaderStyle CssClass="gridheader" />
                <AlternatingRowStyle CssClass="row alt" />
            </asp:GridView>
        </div>
        <br />
        <asp:LinkButton ID="LinkButtonAddSiteAlias" runat="server">Insert</asp:LinkButton><br />
    
       <asp:Panel ID="PanelAddSiteAlias" runat="server">
            <uc1:RoundedPanel ID="rp2" runat="server" Width="400px">
                <div class="grid">
                    <div class="gridview">
                        <div class="gridheader">
                            Add Site Alias
                        </div>
                                  
                        <asp:DetailsView ID="DetailsViewInsertSiteAlias" runat="server" AutoGenerateRows="False" Width="100%"
                            DataSourceID="odsSiteAliases" DefaultMode="Insert" BorderStyle="None" BorderWidth="0px">
                            <Fields>
                                <asp:TemplateField HeaderText="ParentSite" SortExpression="ParentSite">
                                    <InsertItemTemplate>
                                        <cc1:BindableDropDownListExtender ID="BindableDropDownListExtender1" runat="server"
                                            AttachTo="ddlSiteSelection" BoundValueType="Blazing.BusinessObjects.Cms.Site, Blazing.BusinessObjects"
                                            BoundValue='<%# Bind("ParentSite") %>' />
                                        <asp:DropDownList ID="ddlSiteSelection" runat="server" DataSourceID="odsSites" DataTextField="Name"
                                            DataValueField="ID">
                                        </asp:DropDownList>
                                    </InsertItemTemplate>
                                </asp:TemplateField>
                                <asp:BoundField DataField="Name" HeaderText="Name" SortExpression="Name" />
                                <asp:BoundField DataField="Url" HeaderText="Url" SortExpression="Url" />
                                <asp:CommandField ShowInsertButton="True" />                        
                            </Fields>
                            <RowStyle CssClass="row" />
                            <EditRowStyle CssClass="edit-info" />               
                            <PagerStyle BackColor="#284775" ForeColor="White" HorizontalAlign="Center" />
                            <HeaderStyle CssClass="gridheader" />
                            <AlternatingRowStyle CssClass="row alt" />
                        </asp:DetailsView>
                    </div>
                </div>
            </uc1:RoundedPanel>
        </asp:Panel>
   
    
    <ajax:ModalPopupExtender ID="ModalPopupExtender2" runat="server" TargetControlID="LinkButtonAddSiteAlias"
        PopupControlID="PanelAddSiteAlias" PopupDragHandleControlID="PanelAddSiteAliasTitle" SkinID="Popup1">
    </ajax:ModalPopupExtender>
    </ContentTemplate>
    </ajax:TabPanel>
    </ajax:TabContainer> 
    </ContentTemplate>
    </ajax:UpdatePanel>
    
    <asp:ObjectDataSource ID="odsSites" runat="server" DeleteMethod="DeleteSite" InsertMethod="NewSite"
        SelectMethod="GetSites" TypeName="Blazing.WebFacade.SiteController" UpdateMethod="UpdateSite"
        DataObjectTypeName="Blazing.BusinessObjects.Cms.Site">
        <DeleteParameters>
            <asp:Parameter Name="ID" Type="Int32" />
        </DeleteParameters>
    </asp:ObjectDataSource>

    <asp:ObjectDataSource ID="odsSiteAliases" runat="server" DataObjectTypeName="Blazing.BusinessObjects.Cms.SiteAlias"
        DeleteMethod="DeleteSiteAlias" InsertMethod="NewSiteAlias" OldValuesParameterFormatString="original_{0}"
        SelectMethod="GetSiteAliases" TypeName="Blazing.WebFacade.SiteController"></asp:ObjectDataSource>

    <ajax:UpdateProgress runat="server" ID="update" DisplayAfter="50">
        <progresstemplate>
            <uc3:Loading ID="Loading1" runat="server" />
        </progresstemplate>
    </ajax:UpdateProgress>
    <br />
</asp:Content>
